package com.spring.annotation;

import com.spring.beans.MyFactoryBean;
import com.spring.beans.User;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

@Configuration
@ComponentScan(value = "com.spring",excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class, Service.class})
})
public class MainConfig {

    @Bean
    public User user(){
        User user = new User("za", 23);
        return user;
    }


    /**
     * 工厂BeanFactory
     */
    @Bean
    public FactoryBean factoryBean(){
        return new MyFactoryBean();
    }
}
